package org.millioncall.yueyoga.admin.service.hessian.impl;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.List;

import javax.annotation.Resource;

import org.millioncall.yueyoga.admin.model.ClassScheduleModel;
import org.millioncall.yueyoga.admin.model.TinyClass;
import org.millioncall.yueyoga.admin.service.CheduleService;
import org.millioncall.yueyoga.admin.service.ClazzService;
import org.millioncall.yueyoga.admin.service.hessian.ReserveLessianService;

/**
 * 远程订座服务的业务类实现
 * 
 * @author zangjinyu
 * @version 1.0.0
 * @since 1.0.0(2014-10-5)
 *
 */
public class ReserveLessianServiceImpl implements ReserveLessianService {
	@Resource(name = "cheduleService")
	private CheduleService cheduleService;
	@Resource(name = "clazzService")
	private ClazzService clazzService;

	@Override
	public List<List<ClassScheduleModel>> getScheduleLessionList(
			String classId, Date from, Integer count) {
		List<List<ClassScheduleModel>> result = new ArrayList<List<ClassScheduleModel>>();
		Calendar can = Calendar.getInstance();
		can.setTime(from);
		SimpleDateFormat sdf = new SimpleDateFormat("MM-dd");

		String firstDay = sdf.format(can.getTime());
		result.add(cheduleService.findScheduleInfoList(classId, firstDay, null,
				null));

		for (int i = 0; i < count - 1; i++) {
			can.add(Calendar.DAY_OF_MONTH, 1);
			Date target = can.getTime();
			String kcrq = sdf.format(target);

			List<ClassScheduleModel> csmList = cheduleService
					.findScheduleInfoList(classId, kcrq, null, null);
			result.add(csmList);
		}
		return result;
	}

	@Override
	public List<TinyClass> getAllClasses() {
		return clazzService.findAllClassTiny(new HashMap<String, Object>());
	}
}
